package com.itheima.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServlerContext extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext context = getServletContext();
//        String encoding = context.getInitParameter("globalEncoding");
//        System.out.println(encoding);
//        String contextPath = context.getContextPath();
//        System.out.println(contextPath);
//        String realPath = context.getRealPath("/");
//        System.out.println(realPath);
//        String a = context.getRealPath("/a.txt");
//        System.out.println(a);
//        String b= context.getRealPath("/WEB-INF/b.txt");
//        System.out.println(b);
//        String c = context.getRealPath("/WEB-INF/classes/b.txt");
//        System.out.println(c);
        context.setAttribute("username","zhangsan");
    }
}
